/**
 * @USER: Administrator
 * @DATE: 2024/9/21 下午1:03
 * @VERSION: 1.0.0
 */
public class LC997 {
    public static void main(String[] args) {

    }

    public int findJudge(int n, int[][] trust) {
        int[] inDegree = new int[n+1];
        int[] outDegree = new int[n+1];
        for(int[] edge: trust){
            inDegree[edge[1]]++;
            outDegree[edge[0]]++;
        }
        for(int i = 1; i <= n; i++){
            if(outDegree[i] == 0 && inDegree[i] == n-1){
                return i;
            }
        }
        return -1;
    }

}
